/**
 * 
 */
package fr.mynounou.web.model;

import java.io.Serializable;
import java.util.List;

import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;

import org.apache.log4j.Logger;

import fr.mynounou.entities.Utilisateur;
import fr.mynounou.exceptions.dao.NotUniqueException;
import fr.mynounou.web.model.dao.UserDao;

/**
 * @author btavernier
 * 
 */
@SuppressWarnings("serial")
@ManagedBean(name = "UsersManager")
@ApplicationScoped
public class UsersManager implements Serializable {
	@ManagedProperty(value = "#{UserDAO}")
	private UserDao userDao;

	public List<Utilisateur> listUsers() {
		return userDao.listUsers();
	}

	public Utilisateur getUser(String login) {
		try {
			return userDao.findUser(login);
		} catch (NotUniqueException e) {
			Logger.getLogger(getClass()).error(e.toString());
			return null;
		}
	}

	/**
	 * @param userDao
	 *            the userDao to set
	 */
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

}
